package com.flyduck.system.vo.dept.trans;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.flyduck.system.entity.SysDeptEntity;
import com.flyduck.system.vo.dept.SysDeptDetailRespVO;
import com.google.common.base.Function;


/**
 * @program: flyduck-platform
 * @description:
 * @author: flyduck
 * @create: 2021-02-01 12:42
 **/
public class SysDeptEntityToSysDeptDetailRespVO implements Function<SysDeptEntity, SysDeptDetailRespVO> {

    @Override
    public SysDeptDetailRespVO apply(SysDeptEntity entity) {
        SysDeptDetailRespVO sysDeptDetailRespVO = new SysDeptDetailRespVO();
        BeanUtil.copyProperties(entity,sysDeptDetailRespVO);
        sysDeptDetailRespVO.setId(entity.getId()+"");
        if(ObjectUtil.isNotNull(entity.getParentId())){
            sysDeptDetailRespVO.setParentId(entity.getParentId()+"");
        }else {
            sysDeptDetailRespVO.setParentId(null);
        }
        sysDeptDetailRespVO.setSort(String.valueOf(entity.getSort()));
        return sysDeptDetailRespVO;
    }
}
